package com.lanswon.icc.common.core.util;

import lombok.experimental.UtilityClass;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

/**
 * @Description
 * @Author zsw
 * @Date 2019/11/11 10:47
 * @Version V1.0
 **/
@UtilityClass
public class UserUtil {

    /**
     * 获取用户名称
     *
     * @return username
     */
    public String getUsername() {
        Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
        if (authentication == null) {
            return null;
        }
        return authentication.getName();
}


}